import numpy as np

# ==============滚动轴==============================
# rollaxis(a，axis, start)  （2，3，4）转换为（2，4，3）
# a     数组
# axis  要滚动的轴的序号
# start 滚动到什么位置

# 轴滚动是改变下标，下标改变位置也改变，即使改变的数相等
c = np.arange(27).reshape(3,3,3)
print(c)
c1 = np.rollaxis(c,2,0)
print(c1)

a = np.arange(24).reshape(4,3,2)
print(a)

# 查找数值在列表的位置，输出坐标
print(np.where(a == 6))  # (array([1]), array([0]), array([0]))

# 将a列表中的的第二位参数改为第一位参数
b = np.rollaxis(a,2,0)
print(b)
print(b.shape)
b = np.rollaxis(a,0,2)
print(b)
print(b.shape)

# ===============交换轴==============================
# 将第二、第三个参数轴交换位置
a = np.arange(8).reshape(2,2,2)
print(a)
print(np.where(b == 2))
b = np.swapaxes(a,0,2)
print(b)
b = np.swapaxes(a,2,0)
print(b)

# b = np.rollaxis(a,2,3)
# print(b)
# print(np.where(b == 2))
# b = np.rollaxis(a,0,1)
# print(b)
# print(np.where(b == 2))